package wiki.tools.vidition.droid.util;

import java.io.StringReader;
import java.util.ArrayList;
import java.util.List;
import org.dom4j.Document;
import org.dom4j.DocumentException;
import org.dom4j.Element;
import org.dom4j.io.SAXReader;
import org.xml.sax.InputSource;
import android.text.TextUtils;
import android.util.Log;

public class GetDataByUri {
	private static final String TAG = "GetDataByUri";

	@SuppressWarnings("unchecked")
	public static String getUrlContent(String url, ArrayList<String> s) {
		HttpClient client = new HttpClient();
		String htmlContent = client.getMethod(url, false);
		Log.e(TAG, "html = " + htmlContent);
		if (!TextUtils.isEmpty(htmlContent)) {
			StringReader reader = new StringReader(htmlContent);
			Document doc;
			try {
				doc = new SAXReader().read(new InputSource(reader));
				List<Element> list = doc.selectNodes("/api/parse");
				Element element = list.get(0);
				String string = element.elementText("text");
				reader.close();
				return string;
			} catch (DocumentException e) {
			}
		}
		return null;
	}
}